package com.hj.lib.entity;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.hj.lib.util.DevUtil;
import com.hj.lib.util.HjTioUtil;

import java.util.Map;

/**
 * $.ajax后需要接受的JSON
 *
 * @author
 */
public class AjaxJson {


	public static enum HjTioCode {
		RegDev(10001),
		RLTG(10002),
		TZRH(10003),
		FQQM(10004),//发起签名
		QMWC(10005),//签名完成
		TCHY(10006),//退出会议
		TCQM(10007),//退出簽名
		CQSB(10008),//重启设备
		TEST(20001);
		private final int value;
		HjTioCode(int value) {
			this.value = value;
		}
		public int getValue() {
			return value;
		}
	}

	private boolean success = true;// 是否成功
	private String msg = "操作成功";// 提示信息
	private Object obj = null;// 其他信息
	private String mac;
	private String ids;
	private HjTioCode code;
	private Map<String, Object> attributes;// 其他参数

	public Map<String, Object> getAttributes() {
		return attributes;
	}

	public void setAttributes(Map<String, Object> attributes) {
		this.attributes = attributes;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getObj() {
		return obj;
	}

	public void setObj(Object obj) {
		this.obj = obj;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getJsonStr() {
		JSONObject obj = new JSONObject();
		obj.put("success", this.isSuccess());
		obj.put("msg", this.getMsg());
		obj.put("obj", this.obj);
		obj.put("attributes", this.attributes);
		return obj.toJSONString();
	}

	public String getMac() {
		try {
			if (StrUtil.isBlank(mac)) {
				this.mac = DevUtil.getMACAddress();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return mac;
	}

	public void setMac(String mac) {

		this.mac = mac;

	}

	public HjTioCode getCode() {
		return code;
	}

	public void setCode(HjTioCode code) {
		this.code = code;
	}

	public String getIds() {
		ids = HjTioUtil.ids;
		return ids;
	}

	public void setIds(String ids) {
		this.ids = ids;
	}
}
